//
//  WGQAlbumDateHeaderCollectionViewCell.m
//  meiang_edu
//
//  Created by gq w on 2018/10/2.
//  Copyright © 2018 com.meiang.meiang_edu. All rights reserved.
//

#import "WGQAlbumDateHeaderCollectionViewCell.h"
#import "WGQAlbumDateHeaderModel.h"

@interface WGQAlbumDateHeaderCollectionViewCell ()

@property (nonatomic,strong) UILabel * weekLabel;
@property (nonatomic,strong) UILabel * calendarLbael;//公历
@property (nonatomic,strong) UILabel * lunarCalendar;//农历
@property (nonatomic,strong) UIView * tagBackView;//圆形的d选中标识

@end

@implementation WGQAlbumDateHeaderCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame])
    {
        [self addSubViews];
    }
    return self;
}

- (void)addSubViews
{
    self.weekLabel = [[UILabel alloc] init];
    self.weekLabel.textColor = FFColor(0x666666);
    self.weekLabel.font = [UIFont fontWithName:kMainFontFormat size:14 * kScale];
    self.weekLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.weekLabel];
    [self.weekLabel mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.top.equalTo(self.contentView.mas_top).offset(12 * kScale);
         make.left.and.right.equalTo(self.contentView);
     }];
    
    self.tagBackView = [[UIView alloc] init];
    self.tagBackView.backgroundColor = PROJECT_DEFAULT_COLOR;
    self.tagBackView.layer.masksToBounds = YES;
    self.tagBackView.layer.cornerRadius = 15 * kScale;
    [self.contentView addSubview:self.tagBackView];
    self.tagBackView.hidden = YES;
    [self.tagBackView mas_makeConstraints:^(MASConstraintMaker *make)
    {
        make.top.equalTo(self.weekLabel.mas_bottom);
        make.centerX.equalTo(self.contentView.mas_centerX);
        make.width.and.height.mas_equalTo(30 * kScale);
    }];
    
    self.calendarLbael = [[UILabel alloc] init];
    self.calendarLbael.textColor = FFColor(0x666666);
    self.calendarLbael.font = [UIFont fontWithName:kMainFontFormat size:10 * kScale];
    self.calendarLbael.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.calendarLbael];
    [self.calendarLbael mas_makeConstraints:^(MASConstraintMaker *make)
    {
        make.left.and.top.and.right.equalTo(self.tagBackView);
    }];
    
    self.lunarCalendar = [[UILabel alloc] init];
    self.lunarCalendar.textColor = FFColor(0x999999);
    self.lunarCalendar.font = [UIFont fontWithName:kMainFontFormat size:10 * kScale];
    self.lunarCalendar.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.lunarCalendar];
    [self.lunarCalendar mas_makeConstraints:^(MASConstraintMaker *make)
    {
        make.bottom.and.left.and.right.equalTo(self.tagBackView);
    }];
}

- (void)setObject:(id)object
{
    if ([object isKindOfClass:[WGQAlbumDateHeaderModel class]])
    {
        WGQAlbumDateHeaderModel * model = object;
        self.calendarLbael.text = model.topDateStr;
        self.lunarCalendar.text = model.bottomDateStr;
        if (model.isSelect == YES)
        {
            self.tagBackView.hidden = NO;
            self.calendarLbael.textColor = [UIColor whiteColor];
            self.lunarCalendar.textColor = [UIColor whiteColor];
        }
        else
        {
            self.tagBackView.hidden = YES;
            self.calendarLbael.textColor = FFColor(0x666666);
            self.lunarCalendar.textColor = FFColor(0x999999);
        }
    }
}

- (void)setWeek:(id)week
{
    if ([week isKindOfClass:[NSString class]])
    {
        self.weekLabel.text = week;
    }
}

@end
